package com.wzh.springbootinit.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wzh.apiCommon.model.entity.InterfaceInfo;
import com.wzh.springbootinit.common.ErrorCode;
import com.wzh.springbootinit.exception.BusinessException;
import com.wzh.springbootinit.mapper.InterfaceInfoMapper;
import com.wzh.springbootinit.service.InterfaceInfoService;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
* @author Admin
* @description 针对表【interface_interfaceInfo(接口信息)】的数据库操作Service实现
* @createDate 2023-03-30 22:19:48
*/
@Service
public class InterfaceInfoServiceImpl extends ServiceImpl<InterfaceInfoMapper, InterfaceInfo>
implements InterfaceInfoService {

    @Override
    public void validInterfaceInfo(InterfaceInfo interfaceInfo, boolean b) {
            if (interfaceInfo == null) {
                throw new BusinessException(ErrorCode.PARAMS_ERROR);
            }

                Long id = interfaceInfo.getId();
                String name = interfaceInfo.getName();
                String description = interfaceInfo.getDescription();
                String url = interfaceInfo.getUrl();
                String requestHeader = interfaceInfo.getRequestHeader();
                String responseHeader = interfaceInfo.getResponseHeader();
                interfaceInfo.setStatus(1);
                Integer status = interfaceInfo.getStatus();
                String method = interfaceInfo.getMethod();
                Long userid = interfaceInfo.getUserid();
                Date createTime = interfaceInfo.getCreateTime();
                Date updateTime = interfaceInfo.getUpdateTime();
                Integer isDelete = interfaceInfo.getIsDelete();
                            // 创建时，所有参数必须非空
            if (b) {
                if (StringUtils.isAnyBlank(name, description, url, requestHeader, responseHeader,method) || ObjectUtils.anyNull(status)) {
                    throw new BusinessException(ErrorCode.PARAMS_ERROR);
                }
            }
        }



}

